<template>
	<view class="">
		<view class="s-input-wrap" style="margin:0">
			<view class="s-input-box flex-row">
				<text class="black-text">库位号</text>
				<input  v-model="form.binNo" auto-focus="true" class="s-input flex1" placeholder="扫描 / 输入库位号" />
				<image class="s-input-icon" src="/static/images/scan.png"></image>
			</view>
			<view class="s-input-box flex-row">
				<text class="black-text">料架号</text>
				<input  v-model="form.shelfNo" class="s-input flex1" placeholder="扫描 / 输入料架号" />
				<image class="s-input-icon" src="/static/images/scan.png"></image>
			</view>
			<view class="s-input-box flex-row">
				<text class="black-text">托盘号</text>
				<input v-model="form.trayNo" @confirm="inputTrayNo" class="s-input flex1" placeholder="扫描 / 输入托盘号" />
				<image class="s-input-icon" src="/static/images/scan.png"></image>
			</view>
			<view class="s-input-box flex-row-between">
				<text class="black-text font-30">采购入库单号</text>
				<text class="black-text font-30">{{form && form.billNo?form.billNo:'---'}}</text>
			</view>
		</view>
		<view class="content-list-total flex-row-between">
			<button @click="submit" class="botton p-botton botton-big">确定</button>
		</view>
	</view>
</template>

<script>
	import { validNum } from "@/utils/common"
	import { bind,getBillProductList } from "./api"
	
	export default {
		data() {
			return {
				form:{
				}
			}
		},
		methods:{			
			inputTrayNo(){
				getBillProductList({
					trayNo:this.form.trayNo,
				}).then(res => {
					if (res.code == 200) {
						if(!!res.rows){
							this.$set(this.form,'billNo',res.rows[0].erpInBillNo);
						}
						else{
							this.$set(this.form,'billNo','');
						}
					} else {
						res.msg && this.$modal.confirmClose(res.msg)
					}
				})
			},
			submit(){
				if (!this.form.binNo ) {
				  this.$modal.msg("请输入库位号")
				} else if (!this.form.shelfNo  ) {
				  this.$modal.msg("请输入料架号")
				}else if (!this.form.trayNo  ) {
				  this.$modal.msg("请输入托盘号")
				} else{
					this.$modal.confirm('是否确认上架').then(() => {
						this.$modal.loading("上架中...")
						var data={
							"binNo":this.form.binNo,
							"shelfNo":this.form.shelfNo,
							"trayNo":this.form.trayNo,
							"billType":1
						}
						bind(data).then(res=>{
							this.$modal.closeLoading()
							console.log(res)
							if(res.code == 200){
								this.$modal.msgSuccess("上架成功")								
								this.form = {
									shelfNo:'',
									trayNo:'',
									billNo:''
								}
							} else {
								res.msg && this.$modal.confirmClose(res.msg)
							}
						})
					})
				}
			},
		}
	}
</script>

<style>
</style>
